<?php
/**
 * Created by PhpStorm.
 * User: hebidu
 * Date: 15/12/31
 * Time: 14:54
 */

namespace Xbd\Api;


use Common\Api\Api;
use Xbd\Model\PostInfoModel;

class PostInfoApi extends Api {


    /**
     * 获取一条信息
     */
    const GET_INFO = "Xbd/PostInfo/getInfo";

    /**
     * 查询
     */
    const QUERY = "Xbd/PostInfo/query";


    const queryNoPaging = "Xbd/PostInfo/queryNoPaging";

    /**
     * 根据id保存
     */

    const SAVE_BY_ID = "Xbd/PostInfo/saveByID";

    /**
     * 增量函数
     */
    const UPDATE_VIEW = "Xbd/PostInfo/setInc";

    /**
     * 查询指定条数记录
     */
    const QUERY_LIMIT = "Xbd/PostInfo/queryLimit";

    public function _init(){
        $this->model = new PostInfoModel();
    }


    public function queryLimit($map=null,$order=null,$limit=null){
        $query = $this->model;

        if(!is_null($map)){
            $query = $query->where($map);
        }
        if($order!=null){
            $query = $query->order($order);
        }
        if($limit!=null){
            $query = $query->limit($limit);
        }

        $list = $query->select();

        if($list==false){
            $error = $this -> model -> getDbError();
            return $this->apiReturnErr($error);
        }else{
            return $this->apiReturnSuc($list);
        }

    }
}